package com.igoal.dao;

import java.util.List;

import com.igoal.entity.UserGoalEntry;
import com.igoal.entity.UserGoalPk;

/**
 * DAO for {@link UserGoalEntry} entity
 * @author Tri
 * @since 6/19/2010
 */
public interface UserGoalEntryDAO extends GenericDao<UserGoalEntry, Long> {
	/**
	 * Find by foreign key
	 * @param userId user identifier
	 * @param goalId goal identifier
	 * @return list of {@link UserGoalEntry}
	 */
	List<UserGoalEntry> findByFK(Long userId, Long goalId);
	
	/**
	 * Find by foreign key
	 * @param fk {@link UserGoalPk} userGoal primary key
	 * @return list of {@link UserGoalEntry}
	 */
	List<UserGoalEntry> findByFK(UserGoalPk fk);
	
	/**
	 * List a number of entries of user by order property in descending
	 * @param userId
	 * @param numberOfEntries number of entries want to list
	 * @param orderBy the property use to order
	 * @return list of {@link UserGoalEntry}
	 */
	List<UserGoalEntry> listEntriesByUser(Long userId, int numberOfEntries, String orderBy);
	
	/**
	 * List a number of entries of goal by order property in descending
	 * @param goalId
	 * @param numberOfEntries number of entries want to list
	 * @param orderBy the property use to order
	 * @return list of {@link UserGoalEntry}
	 */
	List<UserGoalEntry> listEntriesByGoal(Long goalId, int numberOfEntries, String orderBy);
	
	/**
	 * Count goal entries
	 * @param userId user id (optional)
	 * @param goalId goal id (optional)
	 * @return
	 */
	int countEntries(Long userId, Long goalId);
}
